import React from "react";

const Defund = () => {

    const [searchParams] = React.Router.useSearchParams()

    let [orderid, SetOrderid] = React.useState(searchParams.get('orderid') ? searchParams.get('orderid') : 0)

    const submit = async (value: any) => {
        value.id = orderid

        var result = await React.HTTP.post('/order/defund',value)

        if(result.code == 0){
            React.error(result.msg, () => {})
            return false  
        }else{
            React.success(result.msg)
        }
    }
    
    return (
        <>
            <React.UI.NavBar back='返回' onBack={() => React.navigate(-1)}>
                退款申请
            </React.UI.NavBar>

            <React.UI.Form
                name='form'
                layout='horizontal'
                mode='card'
                onFinish={submit}
                footer={
                    <React.UI.Button block type='submit' color='primary' size='large'>
                     提交申请
                    </React.UI.Button>
                }
            >
                <React.UI.Form.Item name="defund" label="退款原因" rules={[{ required: true }]}>
                    <React.UI.TextArea 
                        placeholder='请输入退款原因'
                        showCount
                        maxLength={100}
                    />
                </React.UI.Form.Item>

            </React.UI.Form>
        </>
    )
}


export default Defund;